@extends('admin.base')
    @section('content')
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            图书列表输出表
            <small>preview of simple tables</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">图书列表信息</a></li>
            <li class="active">图书列表</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 图书列表管理</h3>
				  <div class="box-tools">
				  <form action="{{url('admin/list')}}" method="get">
                    <div class="input-group" style="width: 150px;">
                      <input type="text" name="name" class="form-control input-sm pull-right" placeholder="图书名"/>
                      <div class="input-group-btn">
                        <button class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
                      </div>
                    </div>
					</form>
                  </div>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered">
                    <tr>
                      <th style="width:60px">id</th>
                      <th>pid</th>
                      <th>书名</th>
                      <th>图片名</th>
                      <th>图片地址</th>
                      <th>标题</th>
                      <th>文字</th>
                      <th>评论数</th>
                      <th>作者</th>
                      <th>上线时间</th>
                      <th>出版社</th>
                      <th>主要内容</th>
                      <th>现价</th>
                      <th>原价</th>
                      <th>评分</th>
                      <th>销量</th>
                      <th>促销</th>
                      <th>折扣</th>
                      <th>预售</th>
                     
                      <th>状态</th>
                      <th style="width: 100px">操作</th>
                    </tr>
                  @foreach ($list as $v)
                    <tr> 
                      <td>{{$v->id}}</td>
                      <td>{{$v->pid}}</td>
                      <td>{{$v->name}}</td>
                      <td><img src="/list/uploads/s_{{$v->photo}}"/></td>
                      <td>{{$v->src}}</td>
                      <td>{{$v->title}}</td>
                      <td>{{$v->content}}</td>
                      <td>{{$v->num}}</td>
                      <td>{{$v->auth}}</td>
                      <td>{{$v->time}}</td>
                      <td>{{$v->chubanshe}}</td>
                      <td><button onclick="doShow({{$v->id}})" class="btn btn-xs btn-success">主要内容</button></td>
                      <td>{{$v->newprice}}</td>
                      <td>{{$v->oldprice}}</td>
                      <td>
						 <button class="btn btn-xs btn-warning">
                        @for($i=0;$i<$v->level;$i++)
                          ★
                        @endfor
                        </button>
					  </td>
					  <td>{{$v->xiaoliang}}</td>
					  <td>@if($v->cuxiao == 1)
							<button  class="btn btn-xs btn-warning">
							<a href="{{url('admin/docu')}}?id={{$v->id}}">促销</a>
							</button>
							@endif
							@if($v->cuxiao == 0)	
							<button class="btn btn-xs btn-warning">
							<a href="{{url('admin/docu')}}?id={{$v->id}}">正常</a>
							</button>
							@endif
					  </td>
					  <td>{{round($v->newprice/$v->oldprice*10,2)}}</td>
					  <td>@if($v->yushou == 1)
							<button class="btn btn-xs btn-warning">
							<a href="{{url('admin/doyu')}}?id={{$v->id}}">预售</a>
							</button>
							@endif
							@if($v->yushou == 0)
							<button class="btn btn-xs btn-warning">
							<a href="{{url('admin/doyu')}}?id={{$v->id}}">正常</a>
							</button>
							@endif
					  </td>
					  
                      <td>{{$v->status}}</td>
                      <td><button onclick="doDel({{$v->id}})" class="btn btn-xs btn-danger">删除</button> 
                      <a href="{{url('admin/list')}}/{{$v->id}}/edit"><button class="btn btn-xs btn-primary" >编辑</button></a></td> 
                    </tr>
                  @endforeach
                   
                  </table>
                </div><!-- /.box-body -->
                <div class="box-footer clearfix">
                 {!! $list->appends($params)->render() !!}
                </div>
              </div><!-- /.box -->

              
              
            </div><!-- /.col -->
            
          </div><!-- /.row -->
         
        </section><!-- /.content -->
        <form action="" style="display:none;" id="mydeleteform" method="post">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <input type="hidden" name="_method" value="DELETE">
        </form>
		<form action="" style="display:none;" id="myshowform" method="get">
		</form>
    @endsection
    
    
    @section("myscript")
	<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
           <!-- 此处填充 -->
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="saveConfig()" class="btn btn-primary">提交</button>
          </div>
        </div>
      </div>
    </div>
      <script type="text/javascript">
           //执行删除
           function doDel(id){
				Modal.confirm({msg:'是否删除此类别？'}).on(function (e){
					if(e){
						var form = document.getElementById("mydeleteform");
						form.action = "{{URL('/admin/list')}}/"+id;
						form.submit(); 
					}
				});
			}
			function doShow(id){
				$("#myshowform").attr("action","{{url('admin/list/')}}/"+id).submit();
			}
			function doCu(id){
				$("#myshowform").attr("action","{{url('admin/docu')}}/")+id.submit();
			}
      </script>
    @endsection